import { defineStore } from "pinia";

const mainStore = defineStore("mainStore", {
  persist: true,
  state: () => {
    return {
      condition: "star",
    };
  },
  actions: {},
});

const aliveStore = defineStore("aliveStore", {
  persist: true,
  state: () => {
    return {};
  },
  actions: {
    changeKeepPages(state: any, status: any) {
      state.keepPages = status;
    },
    keepThisPage(state: any, status: any) {
      const arr = state.keepPages.split(",");
      arr.push(status);
      state.keepPages = arr + "";
    },
    removeThisPage(state: any, status: any) {
      const arr = state.keepPages.split(",");
      const index = arr.findIndex((x: any) => x === status);
      if (index > 0) {
        arr.splice(index, 1);
      }
      state.keepPages = arr + "";
    },
  },
});

export { mainStore, aliveStore };
